﻿using System;
using System.Data.Entity.ModelConfiguration;

namespace Supermodel.DomainModel
{
    public class BinaryFile : IComparable
    {
        public string Name { get; set; }
        public byte[] BinaryContent { get; set; }

        public int CompareTo(object obj)
        {
            var typedObj = (BinaryFile)obj;
            if (Name == null) return 0; //if we are an empty object, we say it equals b/c then we do not override db value
            int result = Name.CompareTo(typedObj.Name);
            if (result != 0) return result;
            return BinaryContent.GetHashCode().CompareTo(typedObj.GetHashCode());
        }
    }

    public class BinaryFileTypeMapping : ComplexTypeConfiguration<BinaryFile>
    {
        public BinaryFileTypeMapping()
        {
            Property(o => o.Name);
            Property(o => o.BinaryContent);
        }
    }
}
